import turtle
import random

points = []
def gen_points():
    """生成point 点"""
    for i in range(3):
        y = random.randint(-340, 340)
        points.append([340, y])


def func_click(x,y):
    star[1] += 20


def draw():
    """绘制界面"""
    global n
    turtle.clear()
    a = 0
    if star:
        turtle.up()
        turtle.goto(star)
        turtle.dot(20, "blue")
        if star[1] > 340:
            a = 1
        star[1] -= 10


    pop = []
    if n == 5:
        gen_points()
        n = 0
    else:
        n += 1
    for point in points:
        turtle.up()
        turtle.goto(point)
        turtle.down()
        turtle.dot(20, 'cyan')
        if star and star[0]>point[0]-10 and star[0]<point[0]+10 \
            and star[1]>point[1]-10 and star[1]< point[1]+10:
            a = 1
        point[0]-=10
        if point[0]<=-340:
            pop.append(point)
    for i in range(len(pop)):
        points.remove(pop[i])
    if a==0:
        turtle.ontimer(draw, 200)

def gen_star():
    global star
    star = [0, 340]
if __name__ == '__main__':
    star =[]
    n= 0
    turtle.tracer(False)
    gen_points()
    draw()
    turtle.onscreenclick(func_click)
    turtle.ontimer(gen_star, 3000)
    turtle.done()

